﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


using Meqs.Entity;
using Meqs.Logic.Interface;
using log4net;

namespace Meqs.Logic.Implement
{
    public class KindSettingsEducationLogic : CommonLogic<KindSettingsEducation, int>, IKindSettingsEducationLogic
    {
        public void UpdateCatch(Hashtable ht)
        {
            try
            {
                string statementName = "KindSettingsEducation.UpdateCatch";
                ExecuteUpdate(statementName, ht);
            }
            catch (Exception ex)
            {
                ILog _log = LogManager.GetLogger("DatabaseOp");
                _log.Error("删除对象出错：" + ex.Message, ex);
                throw;
            }
        }
        public void CreatExamSettingParamer(int grade, int classtype, int examid, string schoolmark, string subjectIds)
        {
            try
            {
                string statementName = "KindSettingsEducation.FindLaskExamSetting";
                Hashtable ht = new Hashtable();
                ht.Add("Grade", grade);
                ht.Add("Type", classtype);
                ht.Add("SubjectIds", subjectIds);
                IList<KindSettingsEducation> dses = ExecuteQueryForList<KindSettingsEducation>(statementName, ht);
                foreach (KindSettingsEducation d in dses)
                {
                    d.ExamID = examid;
                    Create(d);
                }
            }
            catch (Exception ex)
            {
                ILog _log = LogManager.GetLogger("DatabaseOp");
                _log.Error("考试参数创建：" + ex.Message, ex);
                throw;
            }
        }
        #region Implementation of ICommonLogic<KindSettingsEducation, int>

        /// <sammury>
        /// 创建对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(KindSettingsEducation entity)
        {
            return CreateObject(entity);
        }

        /// <sammury>
        /// 更新对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(KindSettingsEducation entity)
        {
            return UpdateObject(entity);
        }

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public int Delete(int entityId)
        {
            return DeleteObject(entityId);
        }

        /// <summary>
        /// 删除所有对象
        /// </summary>
        /// <returns></returns>
        public int DeleteAll()
        {
            return DeleteAllObject();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public KindSettingsEducation FindById(int entityId)
        {
            return FindObjectById(entityId);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount()
        {
            return FindObjectByCount();
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<KindSettingsEducation> FindAll()
        {
            return FindAllObject();
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<KindSettingsEducation> FindAll(Hashtable table)
        {
            return FindObject(table);
        }

        #endregion
    }
}